<?php

/**
 * Name: 微信用户模型层
 * User: Silent
 * Date: 2025-09-20
 * Time: 22:44:45
 */

namespace App\Models\Auth;

use App\Models\Config\Employee;
use DateTimeInterface;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class WechatUser extends Model
{
    use HasFactory, SoftDeletes;

    protected $table = 'wechat_user';

    protected $guarded = [];

    // 禁用Laravel默认的时间戳管理
    public $timestamps = false;

    protected $casts = [
        'sex' => 'integer',
    ];

    protected static $logName = 'wechat_user';

    protected function serializeDate(DateTimeInterface $date): string
    {
        return $date->format('Y-m-d H:i:s');
    }

    public function employee()
    {
        return $this->hasOne(Employee::class, 'wechat_user_id', 'id');
    }
}
